﻿Public Class Cliente
    Private cli As Datos.clientes
    Private Shared clienteC As Cliente = Nothing
    Private Sub Cliente_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cli = Datos.clientes.Instanciar
        Me.BindingNavigator1.BindingSource = cli._binding

        Me.TbCedula.DataBindings.Add(New Binding("text", cli._binding, "Cédula"))
        Me.TbNombre.DataBindings.Add(New Binding("text", cli._binding, "Nombre"))
        Me.TbApellidos.DataBindings.Add(New Binding("text", cli._binding, "Apellido"))
        Me.TbDireccion.DataBindings.Add(New Binding("text", cli._binding, "Dirección"))
        Me.TbTelefono.DataBindings.Add(New Binding("text", cli._binding, "Teléfono"))
        Me.TbTelefono2.DataBindings.Add(New Binding("text", cli._binding, "Celular"))


    End Sub
    Public Shared Function instanciar() As Cliente
        If clienteC Is Nothing Then
            clienteC = New Cliente
        End If
        Return clienteC

    End Function
    Private Sub Cliente_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed
        clienteC = Nothing

    End Sub


    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        cli.eliminar()

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        cli.Insertar(Me.TbCedula.Text, Me.TbNombre.Text, Me.TbApellidos.Text, Me.TbDireccion.Text, Me.TbTelefono.Text, Me.TbTelefono2.Text)

    End Sub
End Class